import request from '../utils/request';
import { createTheURL } from '../utils/utils';
import { API } from '../config/api';


// 新增原始订单
export async function postOrderToServer(params) {
  return request(createTheURL(API.originalOrderAPI, 'add'), {
    method: 'POST',
    body: {
      ...params,
    },
  });
}


// 再来一单（拷贝到购物车）
export async function copyToCar(params) {
  return request(createTheURL(API.originalOrderAPI, 'onlyAddToCar'), {
    method: 'PUT',
    body: params,
  });
}

// 取消原始订单
export async function cancelOrder(params) {
  return request(createTheURL(API.originalOrderAPI, 'cancel'), {
    method: 'PUT',
    body: params,
  });
}


// 客户订单查询
export async function searchCustomerOrder(params) {
  return request(createTheURL(API.originalOrderAPI, 'customerOrder'), {
    method: 'POST',
    body: params,
  });
}

// 根据ID查询订单及其明细
export async function searchOrderById(params) {
  return request(createTheURL(API.originalOrderAPI, 'getOrder'), {
    method: 'PUT',
    body: params,
  });
}

// 详细列表查询
export async function getListOrder(params) {
  return request(createTheURL(API.originalOrderAPI, 'listOrder'), {
    method: 'POST',
    body: params,
  });
}
